﻿using System;
using System.ComponentModel;
using System.Windows.Forms;
using OmegaBot;


namespace drone_cc
{
    public partial class droneWarlockSetup : ClassSetupPanel
    {
        droneWarlockCombat combatClass = null;

        public droneWarlockSetup()
        {
            InitializeComponent();
        }

        public droneWarlockSetup(droneWarlockCombat combatClass)
            : base()
        {
            // Save a reference to the combat class so you can get to config!
            this.combatClass = combatClass;
            InitializeComponent();

            // Load from config:

            cbx_UseMount.Checked = combatClass.Ini.GetBoolean("warlock", "usemount", false);
            cbx_SkipLootCheck.Checked = combatClass.Ini.GetBoolean("paladin", "skiplootcheck", false);
            tbx_MountDistance.Text = combatClass.Ini.GetString("warlock", "mountdistance");

            cbx_CombineElementals.Checked = combatClass.Ini.GetBoolean("warlock", "combineitems", false);
            cbx_OpenClams.Checked = combatClass.Ini.GetBoolean("warlock", "openclams", false);

            cbx_EnablePVP.Checked = combatClass.Ini.GetBoolean("warlock", "enablepvp", false);
        }

        // Throw a FormInvalidException if there's a problem!
        public override void ValidateClassSetup()
        {
            int TestIntParsed;
            if (!Int32.TryParse(tbx_MountDistance.Text, out TestIntParsed))
                throw new FormInvalidException("Please input a valid safe mounting distance.", tbx_MountDistance);
            // Parsed ok but is it correct value?
            if (TestIntParsed < 1)
                throw new FormInvalidException("Please input a valid safe mounting distance.", tbx_MountDistance);
            // Ok all things are good.
        }

        public override void CommitValues()
        {
            // ValidateClassSetup already got called and didn't crash, so everything must be ok!


            combatClass.Ini.Set("warlock", "usemount", cbx_UseMount.Checked);
            combatClass.Ini.Set("warlock", "skiplootcheck", cbx_SkipLootCheck.Checked);
            combatClass.Ini.Set("warlock", "mountdistance", tbx_MountDistance.Text);

            combatClass.Ini.Set("warlock", "combineitems", cbx_CombineElementals.Checked);
            combatClass.Ini.Set("warlock", "openclams", cbx_OpenClams.Checked);

            combatClass.Ini.Set("warlock", "enablepvp", cbx_EnablePVP.Checked);

            combatClass.Ini.Save();
        }




    }
}
